package com.example.goodog.items;

import java.util.Date;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;

import com.example.android.wizardpager.AbstractWizardModel;
import com.example.android.wizardpager.AddDogWizardModel;
import com.example.goodog.Utils;
import com.example.goodog.interfaces.IItemWithAge;
import com.example.goodog.interfaces.IItemWithName;
import com.example.goodog.interfaces.IShowChangeLocationButton;
import com.example.goodog.interfaces.IShowEditButton;


public class DogItem extends ListItem implements IShowEditButton, IShowChangeLocationButton, IItemWithName, IItemWithAge {

	public String	Name;
	public boolean	Sex;
	public short	Size;
	public String	PhoneString;
	public String	DateOfBirth;


	public static final Parcelable.Creator<DogItem> CREATOR = new Parcelable.Creator<DogItem>() {
		 
        @Override
        public DogItem createFromParcel(Parcel source) {
            return new DogItem(source);
        }
 
        @Override
        public DogItem[] newArray(int size) {
            return new DogItem[size];
        }
    };

	public DogItem()
	{
	}

	public DogItem(Parcel source) {
		readFromParcel(source);
	}

	public String GetPhoneNumber()
	{
		if(PhoneString == null)
			return "";
		return PhoneString;
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel parcel, int flags) {
		super.writeToParcel(parcel, flags);
		parcel.writeString(Name);
		parcel.writeString(PhoneString);
		parcel.writeString(DateOfBirth);

		parcel.writeInt(Size); 

		parcel.writeByte((byte) (Sex ? 1 : 0)); 
	}
	
	public void readFromParcel(Parcel parcel) {   
		super.readFromParcel(parcel);
		Name = parcel.readString();
		PhoneString = parcel.readString();
		DateOfBirth = parcel.readString();

		Size = (short) parcel.readInt(); 

		byte b = parcel.readByte();
		if(b == 1)
		{
			Sex = true;
		}
		else
		{
			Sex = false;
		}
	}

	@Override
	public DogItem GetInstance() {
		// TODO Auto-generated method stub
		return this;
	}
	

	@Override
	public AbstractWizardModel GetEditDogWizard(Context c) {
		return new AddDogWizardModel(c,this);
	}

	@Override
	public String GetName() {
		// TODO Auto-generated method stub
		return Name;
	}

	@Override
	public Date GetAge() {
		return Utils.StringToDate(DateOfBirth, "MM/yy");
	}
}
